/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.YeastView;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "PitchNotes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PitchNotes.findAll", query = "SELECT p FROM PitchNotes p"),
    @NamedQuery(name = "PitchNotes.findByPitchNoteID", query = "SELECT p FROM PitchNotes p WHERE p.pitchNoteID = :pitchNoteID"),
    @NamedQuery(name = "PitchNotes.findByPitchType", query = "SELECT p FROM PitchNotes p WHERE p.pitchType = :pitchType"),
    @NamedQuery(name = "PitchNotes.findByVolPitched", query = "SELECT p FROM PitchNotes p WHERE p.volPitched = :volPitched"),
    @NamedQuery(name = "PitchNotes.findByPitchTime", query = "SELECT p FROM PitchNotes p WHERE p.pitchTime = :pitchTime")})
public class PitchNotes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "pitchNoteID")
    private Integer pitchNoteID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "pitchType")
    private int pitchType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "volPitched")
    private float volPitched;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PitchTime")
    @Temporal(TemporalType.TIME)
    private Date pitchTime;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "notes")
    private String notes;
    @JoinColumn(name = "yeastGen", referencedColumnName = "YeastGenID", nullable=true)
    @ManyToOne(optional=true)
    private YeastGens yeastGen;
    @JoinColumn(name = "yeast", referencedColumnName = "YID", nullable=true)
    @ManyToOne(optional=true)
    private YeastView yeast;

    public PitchNotes() {
    }

    public PitchNotes(Integer pitchNoteID) {
        this.pitchNoteID = pitchNoteID;
    }

    public PitchNotes(Integer pitchNoteID, int pitchType, float volPitched, Date pitchTime) {
        this.pitchNoteID = pitchNoteID;
        this.pitchType = pitchType;
        this.volPitched = volPitched;
        this.pitchTime = pitchTime;
    }

    public Integer getPitchNoteID() {
        return pitchNoteID;
    }

    public void setPitchNoteID(Integer pitchNoteID) {
        this.pitchNoteID = pitchNoteID;
    }

    public int getPitchType() {
        return pitchType;
    }

    public void setPitchType(int pitchType) {
        this.pitchType = pitchType;
    }

    public float getVolPitched() {
        return volPitched;
    }

    public void setVolPitched(float volPitched) {
        this.volPitched = volPitched;
    }

    public Date getPitchTime() {
        return pitchTime;
    }

    public void setPitchTime(Date pitchTime) {
        this.pitchTime = pitchTime;
    }

    public YeastView getYeastID() {
        return yeast;
    }

    public void setYeastID(YeastView yeast) {
        if(yeast!=null && yeast.getYid()!=null){
            this.yeast = yeast;
        }
    }

    public YeastGens getYeastGenId() {
        return yeastGen;
    }

    public void setYeastGenId(YeastGens yeastGen) {
        if(yeastGen!=null && yeastGen.getYeastGenID()!=null){
            this.yeastGen = yeastGen;
        }
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pitchNoteID != null ? pitchNoteID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PitchNotes)) {
            return false;
        }
        PitchNotes other = (PitchNotes) object;
        if ((this.pitchNoteID == null && other.pitchNoteID != null) || (this.pitchNoteID != null && !this.pitchNoteID.equals(other.pitchNoteID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.PitchNotes[ pitchNoteID=" + pitchNoteID + " ]";
    }
    
}
